$('.site-one-ul>.hov').hover(function () {
    abc($(this).index());
    $('.site-two')
        .stop().animate({
            paddingTop: 86,
            height: 402
        }, 'linear')
        .children()
        .eq($(this).index())
        .stop()
        .fadeIn(800, 'linear')
        .find('li')
        .each(function (oor, ba) {
            setTimeout(() => {
                $(ba).addClass('dh')
                    .css('transform', 'translateY(0px)')
            }, oor * 80)

        })
        .parents('.site-two-item')
        .siblings()
        .css('display', 'none')
}, function () {
    $('.site-two').stop().animate({
            paddingTop: 0,
            height: 0
        }, 'linear')
        .children().eq($(this).index())
        .css('display', 'none')
        .find('li')
        .each(function (index, dom) {
            $(dom).removeClass('dh')
            $(dom).css('transform', 'translateY(20px)')
        })
})
function abc(index) {
    $('.site-two').hover(function () {
        $('.site-two').stop().animate({
                paddingTop: 86,
                height: 402
            }, 'linear')
            .children()
            .each(function(a,dom){$(dom).css('display', 'none')})
            .eq(index)
            .css('display', 'block')
            .find('li')
            .each(function (oor, ba) {
                $(ba).addClass('dh')
                    .css('transform', 'translateY(0px)')
            })
    }, function () {
        $('.site-two').stop().animate({
                paddingTop: 0,
                height: 0
            }, 'linear')
            .children()
            .eq(index)
            .css('display', 'none')
            .find('li')
            .each(function (oor, ba) {
                $(ba).addClass('dh')
                    .css('transform', 'translateY(20px)')
            })
    })
}

$('.move>ul>li>div').each(function(index,dom){
    $(dom).hover(function(){
        if($(this).children().length%2==0){
            $(this).children().each(function(index,dom){
                $(dom).css('zIndex',-index+10)
                if(index==0){
                    $(dom).stop().animate({
                        left:108
                    },'linear')
                }
                if(index==1){
                    $(dom).stop().animate({
                        left:73
                    },'linear')
                }

                if(index==3){
                    $(dom).stop().animate({
                        left:17
                    },'linear')
                }
            })
        }else{
           $(this).children().each(function(index,dom){
                $(dom).css('zIndex',-index+10)
                if(index==0){
                    $(dom).stop().animate({
                        left:98
                    },'linear')
                }
                if(index==1){
                    $(dom).stop().animate({
                        left:63
                    },'linear')
                }
                if(index==2){
                    $(dom).stop().animate({
                        left:27
                    },'linear')
                }
           })
        }
    },
    function(){
        $(this).children().each(function(index,dom){
            $(dom).stop().animate({
                left:45
            },'linear')
            if(index==0){
                $(dom).stop().animate({
                    left:80
                },'linear')
            }
            if(index==1){
                $(dom).stop().animate({
                    left:45
                },'linear')
            }
            
        })
    })
})

$('.site-span-xs').click(function(){
    $(this).stop().animate({left:-400},50,'linear')
    .next().stop().fadeTo(20,1,'linear')
    $('.site-three').stop().animate({
        height:402
    },500)
    .children('.site-three-con')
    .stop().fadeIn(300,'linear').find('input')
    .stop().animate({left:0},300,'linear')
    .next().stop().animate({width:600},500,'linear')
    .parents('.site-three-con-o')
    .next().find('dd').each(function(index,dom){
        setTimeout(()=>{
            $(dom).stop().animate({left:0},400,'linear')
        },50*index)
    })
})

$('.site-span-yc').click(function(){
    $(this).stop().fadeTo(20,0,'linear')
    .prev().stop().animate({left:0},50,'linear')
    $('.site-three').stop().animate({
        height:0
    },500)
    .children('.site-three-con')
    .stop().fadeOut(300,'linear',function(){
        $(this).find('input')
        .css('left','-30px')
        .next()
        .css('width','0')
        .parents('.site-three-con-o')
        .next().find('dd').css('left','100px')
    })
    
})
// 判断用户是否登录
let uname = getCookie('uname')
if(uname==undefined){
    $('.top-right-lore-con').append(`
        <a href="./login.html" class="la">登录</a>
        <a href="./register.html" class="la">注册</a>
    `)
}else{
    $('.top-right-lore-con').append(`
        <a href="#" class="la">我的商城</a>
        <a href="#" class="la">我的订单</a>
        <a href="./login.html" class="la">账号中心</a>
    `)
}
